package com.jdz.gxq.info.common.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.jdz.gxq.info.common.bo.SessionUserInfo;
import com.jdz.gxq.info.common.constant.Constant;

public abstract class CommonAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws java.lang.Exception {

		ActionForward forward = doExecute(mapping, form, request, response);

		return forward;
	}
	
	protected String getUserId(HttpServletRequest request) {
		
		HttpSession session = request.getSession();
		
		SessionUserInfo user = (SessionUserInfo) session.getAttribute(Constant.SEESION_USER_KEY);
		
		return user.getUser().getName();
	}

	public abstract ActionForward doExecute(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception;
}
